<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<title>新增页面</title>
		<link rel="stylesheet" href="${pageContext.request.contextPath}/statics/component/pear/css/pear.css" />
	</head>
	<body>
	<form class="layui-form" action="" method="post">
		<div class="mainBox">
			<div class="main-container">
				<div class="layui-form-item">
					<label class="layui-form-label">用户名称:</label>
					<div class="layui-input-block">
						<input type="text" style="width: 400px"	 name="roleName" lay-verify="title" autocomplete="off" placeholder="请输入角色名称"
							   class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">权限字符串:</label>
					<div class="layui-input-block">
						<input type="text" style="width: 400px" name="roleKey" lay-verify="title" autocomplete="off" placeholder="请输入权限字符串"
							   class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">数据范围:</label>
					<div class="layui-input-block" style="width: 400px">
						<select name="dataScope" lay-filter="aihao">
							<option  value="请选择"></option>
							<option  value= "1">全部数据权限</option>
							<option  value= "2">自定数据权限</option>
							<option  value= "3">本部门数据权限</option>
							<option  value= "4">本部门及以下数据权限</option>
						</select>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">显示顺序:</label>
					<div class="layui-input-block">
						<input type="text" style="width: 400px" name="roleSort" lay-verify="title" autocomplete="off" placeholder="请输入显示顺序"
							   class="layui-input">
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">备注:</label>
					<div class="layui-input-block">
						<input type="text" style="width: 400px" name="remark" lay-verify="title" autocomplete="off" placeholder="请输入权限字符串"
							   class="layui-input">
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">角色状态:</label>
					<div class="layui-input-block">
						<input type="radio" name="status" value="0" title="正常" checked>
						<input type="radio" name="status" value="1" title="删除">
					</div>
				</div>
				</div>
			</div>
		</div>
		<div class="bottom">
			<div class="button-container">
				<button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit=""
						lay-filter="role-save">
					<i class="layui-icon layui-icon-ok"></i>
					提交
				</button>
				<button type="reset" class="pear-btn pear-btn-sm">
					<i class="layui-icon layui-icon-refresh"></i>
					重置
				</button>
			</div>
		</div>
	</form>
		<script src="${pageContext.request.contextPath}/statics/component/layui/layui.js"></script>
		<script src="${pageContext.request.contextPath}/statics/component/pear/pear.js"></script>
		<script>
			layui.use(['form', 'jquery'], function() {
				let form = layui.form;
				let $ = layui.jquery;

				form.on('submit(role-save)', function(data) {
					$.ajax({
						url: '${pageContext.request.contextPath}/role/add',
						data: data.field,
						dataType: 'json',
						// contentType: 'application/json',
						type: 'post',
						success: function(result) {
							if (result = 1) {
								layer.msg(result.msg, {
									icon: 1,
									time: 1000
								}, function() {
									parent.layer.close(parent.layer.getFrameIndex(window
										.name)); //关闭当前页
									parent.layui.table.reload("role-table");
								});
							} else {
								layer.msg(result.msg, {
									icon: 2,
									time: 1000
								});
							}
						}
					})
					return false;
				});
			})
		</script>
		<script>
		</script>
	</body>
</html>